import type { UserLoginType, UserType } from '@/api/login/types';
import { defineStore } from 'pinia';
import { store } from '../index';

interface UserState {
  loginInfo?: UserLoginType;
  rememberMe: boolean;
  roleRouters?: string[] | AppCustomRouteRecordRaw[];
  token: string;
  tokenKey: string;
  userInfo?: UserType;
}

export const useUserStore = defineStore('user', {
  state: (): UserState => ({
    loginInfo: undefined,
    rememberMe: true,
    roleRouters: undefined,
    token: '',
    tokenKey: 'Authorization',
    userInfo: undefined
  }),
  getters: {},
  actions: {},
  persist: true
});

export const useUserStoreWithOut = () => useUserStore(store);
